package com.bamboo.core.config;

import com.bamboo.core.filters.WrapperRequestFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @description 配置注册filter
* @date 2025/3/7 16:07
* @author chenzh
*/
@Configuration
public class FilterConfig {
    @Bean
    public FilterRegistrationBean<WrapperRequestFilter> wrapperRequestFilter() {
        FilterRegistrationBean<WrapperRequestFilter> registrationBean =
                new FilterRegistrationBean<>();
        registrationBean.setFilter(new WrapperRequestFilter());
        registrationBean.addUrlPatterns("/api/*"); // 拦截所有请求
        registrationBean.setOrder(1); // 控制过滤器执行顺序
        return registrationBean;
    }
}
